package com.xian.im.common.exception;

import lombok.Getter;

@Getter
public enum GlobalErrorCode {

    FAILURE(-1,"系统繁忙，请稍后再试"),
    OBJ_NULL(1,"当前对象不能为空"),
    CODE_200(200,"请求成功"),
    UNAUTHORIZED(401,"token不合法"),

    CODE_40000(40000,"失败"),
    CODE_40001(40001,"不合法的凭证类型"),
    CODE_40002(40002,"邮件地址格式错误"),

    CODE_50550(50550,"改服务器发信IP超过邮箱限制"),
    CODE_50535(50535,"发件人账号或密码验证失败"),
    CODE_50536(50536,"发送邮件失败，附件不存在"),
    Upload_file_FAILURE_not_found(50537,"文件上传失败，文件不存在"),
    Upload_file_size_exceeds_limit(50538,"上传文件大小超出限制，上传失败"),

    CONTENT_TYPE_NOT_SUPPORT(61453,"无效的内容参数"),
    METHOD_NOT_SUPPORTED(61452,"不支持的方法"),
    SERVICE_NOT_FOUND(50000,"找不到服务"),
    INVALID_PARAMETER(61451,"无效参数"),
    SYSTEM_INTERNAL_ERROR(61450,"系统错误(system error)"),
    CODE_61602(61502,"必填参数为空"),
    CODE_61503(61503,"不允许重复提交");
    private int code;
    private String message;

    GlobalErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static GlobalErrorCode getDescByCode(int code){
        for (GlobalErrorCode errorCodeEnum:GlobalErrorCode.values()){
            if (errorCodeEnum.getCode()== code){
                return errorCodeEnum;
            }
        }
        return null;
    }

}
